package rents.internal.local;

import rents.User;
import rents.internal.account.Account;

import common.money.MonetaryAmount;
import common.money.Percentage;
import common.repository.Entity;


public class Local extends Entity{
	
	private String number;

	private String name;

	private Percentage benefitPercentage;

	private BenefitAvailabilityPolicy benefitAvailabilityPolicy;

	@SuppressWarnings("unused")
	private Local() {
	}

		public Local(String number, String name) {
		this.number = number;
		this.name = name;
	}

	
	public void setBenefitPercentage(Percentage benefitPercentage) {
		this.benefitPercentage = benefitPercentage;
	}

	
	public void setBenefitAvailabilityPolicy(BenefitAvailabilityPolicy benefitAvailabilityPolicy) {
		this.benefitAvailabilityPolicy = benefitAvailabilityPolicy;
	}

	
	public String getName() {
		return name;
	}

	
	public String getNumber() {
		return number;
	}

	
	public Percentage getBenefitPercentage() {
		return benefitPercentage;
	}

	
	public BenefitAvailabilityPolicy getBenefitAvailabilityPolicy() {
		return benefitAvailabilityPolicy;
	}

	
	public MonetaryAmount calculateBenefitFor(Account account, User user) {
		if (benefitAvailabilityPolicy.isBenefitAvailableFor(account, user)) {
			return user.getAmount().multiplyBy(benefitPercentage);
		} else {
			return MonetaryAmount.zero();
		}
	}

	public String toString() {
		return "Number = '" + number + "', name = '" + name + "', benefitPercentage = " + benefitPercentage
				+ ", benefitAvailabilityPolicy = " + benefitAvailabilityPolicy;
	}
	
	

}
